# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=greenbone-security-assistant
_pkgname=gsad
pkgver=9.0.1
pkgrel=3
pkgdesc="Greenbone Security Assistant (gsa) - OpenVAS web frontend"
url="https://www.openvas.org/"
arch="all !mips !mips64"
license="GPL-2.0-or-later"
depends="wget"
makedepends="cmake doxygen xmltoman graphviz gvm-libs-dev
	libxslt-dev libmicrohttpd-dev py3-polib libgcrypt-dev
	nodejs-current npm yarn clang-dev"
checkdepends="cppcheck"
subpackages="$pkgname-doc $pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/greenbone/gsa/archive/v$pkgver.tar.gz
	$_pkgname.initd
	$_pkgname.confd
	$_pkgname.logrotate
	sys-siglist.patch
	gsa-pid.patch
	gsad-sbin.patch
	musl-stack-size.patch
	remove-husky-git-hook.patch
	"
builddir="$srcdir/gsa-$pkgver"

case "$CARCH" in
	# cppcheck not available
	aarch64|s390x) options="!check";;
esac

build() {
	cmake -B build \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DSYSCONFDIR=/etc \
		-DSBINDIR=/usr/sbin \
		-DLOCALSTATEDIR=/var \
		-DDEFAULT_CONFIG_DIR=/etc/default \
		-DLOGROTATE_DIR=/etc/logrotate.d

	make -C build
}

check() {
	make -C build check
}

package() {
	make -C build DESTDIR="$pkgdir" install
	install -Dm644 "$srcdir"/$_pkgname.logrotate "$pkgdir"/etc/logrotate.d/$_pkgname
	install -Dm755 "$srcdir"/$_pkgname.initd "$pkgdir"/etc/init.d/$_pkgname
	install -Dm644 "$srcdir"/$_pkgname.confd "$pkgdir"/etc/conf.d/$_pkgname
	rm -rf "$pkgdir"/usr/lib/systemd
}

sha512sums="688bde97722f31416406e43230253c05dc8d05eb9fea6d8fd084ec4e748b67bab238f78cc11534e4fc948d911e468d43b5be0b224f17959db5e59faae7f5d086  greenbone-security-assistant-9.0.1.tar.gz
531d6856fa2d6e26bcc9ab1d31bfe65fe4d42954a5fdd66f10cf7898bba36a205ea4089895ffe1c3d6221ff5c841b12eaa8aca1ea3f3f4b9dc63952b881be9b5  gsad.initd
82e988a59165380d4f7a2082087eafb245adfdde8f8841bab2383dc748d74b3ea6fda26bdd27c126f12c58fca2f52d69286af33f180a320ffaeefb4b38d3ce44  gsad.confd
ab43f8c54cf72e2a800bdcf4daebeabfa18a7ef49f098d65e70f97ccab3d36606c353b82b8fd6b4f2cecd289d36f48f805a5c34cba86f8e8c61bf074b0afe695  gsad.logrotate
1fd6585bc5c5131d19d5d89ddc56b683d5ab1b28793059f5b147ad05eb6330b69d590caa2f12afce6da20b1676d8cdd26d90e51d165e94b308643ec7d2525015  sys-siglist.patch
6752bb6834811fc7c1259d2c8a0ae5f25a01de881008f6f6635b1f7a43672b5c1862de5b3591f81d7a2f22258614b71bb6ab588a3930648d9d74ef8a75d28c92  gsa-pid.patch
3afa191863e1056182f8abf7f6d9a65cbd5d3fd69a522c5e414e19fcf2dd6d02eb8b5b2867383eaa659ce913f169c0739a4bc1209996879337b60ccd80d0bcfa  gsad-sbin.patch
ad78cce9f4f21157d679e227698896364c33eac9c5af4228552b61c0f9bde0e3b2743ae6717766acde38d5445d08e60832b2b0418456cdb8a77a91b3c440735b  musl-stack-size.patch
16a4cd1ced3f2ccbeefe41cffc35bfe0fb517cd32cd35bbf549b7ab31625384e88cfd433edf21fbad732116a0f97f319dfee127a3bc1bf1d6ccf9e0ddf1a9ccc  remove-husky-git-hook.patch"
